// 工具类
const app = getApp()
const util = require("../../../utils/util.js")
// 逻辑层
Page({
  // 初始化数据
  data: {
    shareLinkCode: '',      // 分享code码
    shareQrCodeImg: '',      // 二维码图片

    buttonClicked: false, // 防止连续点击问题
    listenerRegistered: false, // 监听是否被注册过
    scrollTop: 0, //滚动的值
    indicatorDots: false,
    autoplay: true,
    interval: 3000,
    duration: 1000,
    circular: true,

    cityDialog: false, // 城市下拉列表弹框
    citySelecteText: '北京', // 当前城市
    cityAreaArray: [], // .vote的height区域集合
    currentIndex: 0, // 锚点当前index

    getTreeBanner: [{
      src:"https://static.isl.ren/islGame_activity/vote-themev1.png"
    }], // 古树banner图列表
    getTreeData: [
      {
        "sheng": "北京",
        "voteItemDTOS": [
          {
            "id": "1003",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "北京潭柘寺银杏树",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/beijingtantuosiyinxingshu260.png",
            "votes": "31",
            "messages": "5",
            "createdAt": "2019-02-20 09:52:08",
            "shareCodeName": "Beijing10001",
            "codeNameCn": "北京市",
            "parentCodeName": "Beijing1001",
            "description": "乾隆皇帝亲笔御封“帝王树”，陪伴寺院走过千年光阴，沐浴佛光，守护寺院，是历史的象征，皇家寺院的标志",
            "sheng": "北京",
            "ranking": 1,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "安徽",
        "voteItemDTOS": [
          {
            "id": "1002",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "安徽省九华山凤凰松",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/anhuishengjiuhuashanfenghuangsong260.png",
            "votes": "11",
            "messages": "0",
            "createdAt": "2019-02-20 09:50:59",
            "shareCodeName": "Jiuhuashan10003",
            "codeNameCn": "九华山",
            "parentCodeName": "Anhui1002",
            "description": "凤凰松以其雄姿和传奇故事成为古今众多诗人，画家，摄影家的赞美诗和优美画幅中的主角，被誉为“天下地一松”",
            "sheng": "安徽",
            "ranking": 2,
            "notVoting": false
          },
          {
            "id": "1001",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "安徽黄山迎客松",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/anhuihuangshanyingkesong260.png",
            "votes": "11",
            "messages": "0",
            "createdAt": "2019-02-20 09:47:45",
            "shareCodeName": "Huangshan10002",
            "codeNameCn": "黄山",
            "parentCodeName": "Anhui1002",
            "description": "此松是国之瑰宝，是黄山的标志性景观",
            "sheng": "安徽",
            "ranking": 3,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "福建",
        "voteItemDTOS": [
          {
            "id": "1005",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "福建水松王",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/fujianshuisongwang260.png",
            "votes": "4",
            "messages": "2",
            "createdAt": "2019-02-20 09:53:10",
            "shareCodeName": "Yongfuzhen10005",
            "codeNameCn": "永福镇",
            "parentCodeName": "Fujian1003",
            "description": "凌天托日月，拄地镇山河的天下第一水松",
            "sheng": "福建",
            "ranking": 4,
            "notVoting": false
          },
          {
            "id": "1004",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "福建大甲镇罗汉松",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/fujiandajiazhenluohansong260.png",
            "votes": "2",
            "messages": "1",
            "createdAt": "2019-02-20 09:52:31",
            "shareCodeName": "Dajiazhen10004",
            "codeNameCn": "大甲镇",
            "parentCodeName": "Fujian1003",
            "description": "该罗汉松为全国最大、最古老的，堪称国宝",
            "sheng": "福建",
            "ranking": 8,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "甘肃",
        "voteItemDTOS": [
          {
            "id": "1006",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "甘肃天水古树群",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/gansutianshuigushuqun260.png",
            "votes": "3",
            "messages": "0",
            "createdAt": "2019-02-20 09:53:48",
            "shareCodeName": "Tianshui10006",
            "codeNameCn": "天水",
            "parentCodeName": "Gansu1004",
            "description": "天水古树以其均衡的高数龄特征,将散漫繁杂的光阴,浓缩在了一圈圈古树的生命痕迹中,表现出极其规律的连续性和完整性",
            "sheng": "甘肃",
            "ranking": 6,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "广东",
        "voteItemDTOS": [
          {
            "id": "1007",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "广州天马河古榕树",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/guangzhoutianmahegurongshu260.png",
            "votes": "2",
            "messages": "1",
            "createdAt": "2019-02-20 09:54:08",
            "shareCodeName": "Tianma10007",
            "codeNameCn": "天马",
            "parentCodeName": "Guangzhou1005",
            "description": "一棵巨大古榕树创造的自然传奇，巴金点赞的小鸟天堂",
            "sheng": "广东",
            "ranking": 9,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "河南",
        "voteItemDTOS": [
          {
            "id": "1008",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "河南嵩阳二将军柏树",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/henansongyangshuyuanerjiangjubaishu260.png",
            "votes": "4",
            "messages": "1",
            "createdAt": "2019-02-20 09:54:35",
            "shareCodeName": "Zhengzhou10008",
            "codeNameCn": "郑州",
            "parentCodeName": "Henan1006",
            "description": "守护嵩阳书院的威武将军",
            "sheng": "河南",
            "ranking": 5,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "黑龙江",
        "voteItemDTOS": [
          {
            "id": "1009",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "黑龙江哈尔滨古梨树",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/heilongjianghaerbingulishu260.png",
            "votes": "0",
            "messages": "0",
            "createdAt": "2019-02-20 09:55:26",
            "shareCodeName": "Haerbin10009",
            "codeNameCn": "哈尔滨",
            "parentCodeName": "Heilongjiang1007",
            "description": "是省内有记载的最古老的野梨树，每每开花犹如撑起白色巨伞，引得游人络绎不绝",
            "sheng": "黑龙江",
            "ranking": 19,
            "notVoting": false
          },
          {
            "id": "1010",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "黑龙江哈尔滨古榆树",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/heilongjianghaerbinguyushu260.png",
            "votes": "0",
            "messages": "0",
            "createdAt": "2019-02-20 09:55:45",
            "shareCodeName": "Haerbin10009",
            "codeNameCn": "哈尔滨",
            "parentCodeName": "Heilongjiang1007",
            "description": "可以带来好运的“神榆”",
            "sheng": "黑龙江",
            "ranking": 20,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "湖北",
        "voteItemDTOS": [
          {
            "id": "1011",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "湖北章台古梅",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/hubeizhangtaigumei260.png",
            "votes": "3",
            "messages": "0",
            "createdAt": "2019-02-20 09:56:00",
            "shareCodeName": "Zhangtai10010",
            "codeNameCn": "章台",
            "parentCodeName": "Hubei1008",
            "description": "天下第一古梅",
            "sheng": "湖北",
            "ranking": 7,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "湖南",
        "voteItemDTOS": [
          {
            "id": "1012",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "湖南长沙罗汉松",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/hunanchangshaluohansong260.png",
            "votes": "0",
            "messages": "0",
            "createdAt": "2019-02-20 09:56:18",
            "shareCodeName": "Changsha10011",
            "codeNameCn": "长沙",
            "parentCodeName": "Hunan1009",
            "description": "岳麓山中的六朝古松，守护千年的长寿罗汉",
            "sheng": "湖南",
            "ranking": 21,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "江苏",
        "voteItemDTOS": [
          {
            "id": "1013",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "江苏南京六朝松",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/jiangsunanjingliuchaosong260.png",
            "votes": "1",
            "messages": "0",
            "createdAt": "2019-02-20 09:56:35",
            "shareCodeName": "Nanjing10012",
            "codeNameCn": "南京",
            "parentCodeName": "Jiangsu1010",
            "description": "千年六朝松：南京城变迁的“见证人”",
            "sheng": "江苏",
            "ranking": 13,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "内蒙古",
        "voteItemDTOS": [
          {
            "id": "1014",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "库布其沙柳",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/kubuqishaliu260v2.png",
            "votes": "0",
            "messages": "2",
            "createdAt": "2019-02-20 09:56:35",
            "shareCodeName": "Kubuqi10013",
            "codeNameCn": "库布其",
            "parentCodeName": "Neimenggu1011",
            "description": "伫立千年，阅尽沧桑而生机蓬勃，世世代代沙漠人心中的图腾，当地人尊它为神树",
            "sheng": "内蒙古",
            "ranking": 22,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "山东",
        "voteItemDTOS": [
          {
            "id": "1015",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "山东莒县浮来山古银杏",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/shandonglvxianfulanshanguyinxing260.png",
            "votes": "0",
            "messages": "0",
            "createdAt": "2019-02-20 09:57:23",
            "shareCodeName": "Lvxian10014",
            "codeNameCn": "莒县",
            "parentCodeName": "Shandong1012",
            "description": "在莒国的土地上，有一座仙山，山上生长着具有3500年寿龄的天下第一银杏树",
            "sheng": "山东",
            "ranking": 23,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "山西",
        "voteItemDTOS": [
          {
            "id": "1018",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "山西太原晋祠周柏",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/shanxitaiyuanjincizhoubai260.png",
            "votes": "0",
            "messages": "0",
            "createdAt": "2019-02-20 09:58:40",
            "shareCodeName": "Taiyuan10015",
            "codeNameCn": "太原",
            "parentCodeName": "Shanxi1013",
            "description": "历代文人赞颂的“晋源之柏”， 阅尽晋阳沧桑",
            "sheng": "山西",
            "ranking": 24,
            "notVoting": false
          },
          {
            "id": "1017",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "山西太原晋祠银杏",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/shanxitaiyuanjinciyinxing260.png",
            "votes": "1",
            "messages": "0",
            "createdAt": "2019-02-20 09:58:04",
            "shareCodeName": "Taiyuan10015",
            "codeNameCn": "太原",
            "parentCodeName": "Shanxi1013",
            "description": "守候500年的浪漫传奇",
            "sheng": "山西",
            "ranking": 14,
            "notVoting": false
          },
          {
            "id": "1016",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "山西太原狄母古树",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/shanxitaiyuandimugushu260.png",
            "votes": "1",
            "messages": "0",
            "createdAt": "2019-02-20 09:57:43",
            "shareCodeName": "Taiyuan10015",
            "codeNameCn": "太原",
            "parentCodeName": "Shanxi1013",
            "description": "狄仁杰母亲所植古槐树",
            "sheng": "山西",
            "ranking": 15,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "陕西",
        "voteItemDTOS": [
          {
            "id": "1026",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "陕西毛主席手植丁香",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/shanxiyananmaozedongshouzhidingxiang260.png",
            "votes": "0",
            "messages": "0",
            "createdAt": "2019-02-20 10:01:28",
            "shareCodeName": "Yanan10022",
            "codeNameCn": "延安",
            "parentCodeName": "Shanxi1014",
            "description": "代表着毛泽东要推翻一个旧世界，更要美化自己的家园，创造拥有这天国之花的人间天堂的决心",
            "sheng": "陕西",
            "ranking": 25,
            "notVoting": false
          },
          {
            "id": "1024",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "陕西王维手植银杏树",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/shanxixianlantianwangweishouzhiyinxingshu260.png",
            "votes": "1",
            "messages": "0",
            "createdAt": "2019-02-20 10:00:51",
            "shareCodeName": "Xian10021",
            "codeNameCn": "西安",
            "parentCodeName": "Shanxi1014",
            "description": "王维诗云文：“杏栽为架，春茅结大宇不知栋里云，去作人间雨”",
            "sheng": "陕西",
            "ranking": 16,
            "notVoting": false
          },
          {
            "id": "1025",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "陕西西安玉兰王",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/shanxixianyulanwang260.png",
            "votes": "0",
            "messages": "0",
            "createdAt": "2019-02-20 10:01:11",
            "shareCodeName": "Xian10021",
            "codeNameCn": "西安",
            "parentCodeName": "Shanxi1014",
            "description": "三月舞动，春暖花开，春满中国·醉西安",
            "sheng": "陕西",
            "ranking": 26,
            "notVoting": false
          },
          {
            "id": "1023",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "陕西千年枣树王",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/shanxiqiannianzaoshuwang260.png",
            "votes": "0",
            "messages": "0",
            "createdAt": "2019-02-20 10:00:33",
            "shareCodeName": "Jiaxian10020",
            "codeNameCn": "佳县",
            "parentCodeName": "Shanxi1014",
            "description": "陕西佳县千年枣树，是中国枣树的活化石",
            "sheng": "陕西",
            "ranking": 27,
            "notVoting": false
          },
          {
            "id": "1022",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "陕西洛南核桃王",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/shanxiluonanhetaowang260.png",
            "votes": "1",
            "messages": "0",
            "createdAt": "2019-02-20 10:00:02",
            "shareCodeName": "Luonan10019",
            "codeNameCn": "洛南",
            "parentCodeName": "Shanxi1014",
            "description": "三个人手拉手才能抱拢的千年核桃王",
            "sheng": "陕西",
            "ranking": 17,
            "notVoting": false
          },
          {
            "id": "1021",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "陕西黄陵轩辕柏",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/shanxihuanglingxuanyuanbai260.png",
            "votes": "0",
            "messages": "0",
            "createdAt": "2019-02-20 09:59:45",
            "shareCodeName": "Huangling10018",
            "codeNameCn": "黄陵",
            "parentCodeName": "Shanxi1014",
            "description": "世界柏树之父",
            "sheng": "陕西",
            "ranking": 28,
            "notVoting": false
          },
          {
            "id": "1020",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "陕西红豆杉王",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/shanxihongdoushanwang260.png",
            "votes": "0",
            "messages": "0",
            "createdAt": "2019-02-20 09:59:18",
            "shareCodeName": "Shangluo10017",
            "codeNameCn": "商洛",
            "parentCodeName": "Shanxi1014",
            "description": "红豆杉王”年年果实累累，葡萄那么大的果子甜甜蜜蜜",
            "sheng": "陕西",
            "ranking": 29,
            "notVoting": false
          },
          {
            "id": "1019",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "陕西汉中武侯祠旱莲",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/shanxihanzhongwuhoucihanlian260.png",
            "votes": "0",
            "messages": "0",
            "createdAt": "2019-02-20 09:58:59",
            "shareCodeName": "Hanzhong10016",
            "codeNameCn": "汉中",
            "parentCodeName": "Shanxi1014",
            "description": "汉中市市花，开在树上的美丽莲花",
            "sheng": "陕西",
            "ranking": 30,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "天津",
        "voteItemDTOS": [
          {
            "id": "1027",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "天津蓟州九龙槐",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/tianjinjizhoujiulonghuai260.png",
            "votes": "0",
            "messages": "0",
            "createdAt": "2019-02-20 10:01:59",
            "shareCodeName": "Jizhou10023",
            "codeNameCn": "蓟州",
            "parentCodeName": "Tianjin1016",
            "description": "因其历史悠久，长势魁伟，被称为“华北第一槐”，也被封为“天津树王”",
            "sheng": "天津",
            "ranking": 31,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "西藏",
        "voteItemDTOS": [
          {
            "id": "1028",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "西藏世界柏树王",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/xizangshijiebaiwangshu260.png",
            "votes": "2",
            "messages": "0",
            "createdAt": "2019-02-20 10:02:30",
            "shareCodeName": "Linzhi10024",
            "codeNameCn": "林芝",
            "parentCodeName": "Xizang1017",
            "description": "生长在雪域圣地的生命柏树",
            "sheng": "西藏",
            "ranking": 10,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "云南",
        "voteItemDTOS": [
          {
            "id": "1030",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "云南昆明九头龙王",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/yunnankunmingjiulongtouwang260.png",
            "votes": "1",
            "messages": "1",
            "createdAt": "2019-02-20 10:03:13",
            "shareCodeName": "Kunming10026",
            "codeNameCn": "昆明",
            "parentCodeName": "Yunnan1018",
            "description": "云南黄连木界的老前辈",
            "sheng": "云南",
            "ranking": 18,
            "notVoting": false
          },
          {
            "id": "1029",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "云南凤庆锦绣茶祖",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/yunnanfengqingjinxiuchazu260.png",
            "votes": "2",
            "messages": "1",
            "createdAt": "2019-02-20 10:02:52",
            "shareCodeName": "Fengqing10025",
            "codeNameCn": "凤庆",
            "parentCodeName": "Yunnan1018",
            "description": "是见证历史的活化石它是祖先留给后人不可多得的历史财富，又是茶树起源地中心和悠久茶历史的有力佐证",
            "sheng": "云南",
            "ranking": 11,
            "notVoting": false
          }
        ]
      },
      {
        "sheng": "浙江",
        "voteItemDTOS": [
          {
            "id": "1032",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "浙江丽水晋朝樟树",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/zhejianglishuijinchaozhangshu260.png",
            "votes": "2",
            "messages": "2",
            "createdAt": "2019-02-20 10:04:14",
            "shareCodeName": "Lishui10028",
            "codeNameCn": "丽水",
            "parentCodeName": "Zhejiang1019",
            "description": "浙江省最大、最老的古树，被称为浙江第一樟树",
            "sheng": "浙江",
            "ranking": 12,
            "notVoting": false
          },
          {
            "id": "1031",
            "objectId": null,
            "voteState": "10",
            "voteId": "101",
            "itemName": "浙江杭州唐樟",
            "imageUrl": "https://static.isl.ren/isl_img/toupiao/gushu/thumbnail/zhejianghangzhoutangzhang260.png",
            "votes": "0",
            "messages": "4",
            "createdAt": "2019-02-20 10:03:34",
            "shareCodeName": "Hangzhou10027",
            "codeNameCn": "杭州",
            "parentCodeName": "Zhejiang1019",
            "description": "新西湖三十六景之一，香樟树中的老鼻祖",
            "sheng": "浙江",
            "ranking": 32,
            "notVoting": false
          }
        ]
      }
],  // 古树列表
    getProvinceData: [// 省市列表数据

    {
      "id": "101",
      "codeName": "Beijing1001",
      "codeNameCn": "北京",
      "parentCodeName": "China",
      "codePath": ",China,Beijing1001,",
      "codeIndex": 1001,
      "codeValue": 1001,
      "codeDesc": "北京",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "102",
      "codeName": "Anhui1002",
      "codeNameCn": "安徽",
      "parentCodeName": "China",
      "codePath": ",China,Anhui1002,",
      "codeIndex": 1002,
      "codeValue": 1002,
      "codeDesc": "安徽",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "103",
      "codeName": "Fujian1003",
      "codeNameCn": "福建",
      "parentCodeName": "China",
      "codePath": ",China,Fujian1003,",
      "codeIndex": 1003,
      "codeValue": 1003,
      "codeDesc": "福建",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "104",
      "codeName": "Gansu1004",
      "codeNameCn": "甘肃",
      "parentCodeName": "China",
      "codePath": ",China,Gansu1004,",
      "codeIndex": 1004,
      "codeValue": 1004,
      "codeDesc": "甘肃",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "105",
      "codeName": "Guangzhou1005",
      "codeNameCn": "广东",
      "parentCodeName": "China",
      "codePath": ",China,Guangzhou1005,",
      "codeIndex": 1005,
      "codeValue": 1005,
      "codeDesc": "广东",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "106",
      "codeName": "Henan1006",
      "codeNameCn": "河南",
      "parentCodeName": "China",
      "codePath": ",China,Henan1006,",
      "codeIndex": 1006,
      "codeValue": 1006,
      "codeDesc": "河南",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "107",
      "codeName": "Heilongjiang1007",
      "codeNameCn": "黑龙江",
      "parentCodeName": "China",
      "codePath": ",China,Heilongjiang1007,",
      "codeIndex": 1007,
      "codeValue": 1007,
      "codeDesc": "黑龙江",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "108",
      "codeName": "Hubei1008",
      "codeNameCn": "湖北",
      "parentCodeName": "China",
      "codePath": ",China,Hubei1008,",
      "codeIndex": 1008,
      "codeValue": 1008,
      "codeDesc": "湖北",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "109",
      "codeName": "Hunan1009",
      "codeNameCn": "湖南",
      "parentCodeName": "China",
      "codePath": ",China,Hunan1009,",
      "codeIndex": 1009,
      "codeValue": 1009,
      "codeDesc": "湖南",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "110",
      "codeName": "Jiangsu1010",
      "codeNameCn": "江苏",
      "parentCodeName": "China",
      "codePath": ",China,Jiangsu1010,",
      "codeIndex": 1010,
      "codeValue": 1010,
      "codeDesc": "江苏",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "111",
      "codeName": "Neimenggu1011",
      "codeNameCn": "内蒙古",
      "parentCodeName": "China",
      "codePath": ",China,Neimenggu1011,",
      "codeIndex": 1011,
      "codeValue": 1011,
      "codeDesc": "内蒙古",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "112",
      "codeName": "Shandong1012",
      "codeNameCn": "山东",
      "parentCodeName": "China",
      "codePath": ",China,Shandong1012,",
      "codeIndex": 1012,
      "codeValue": 1012,
      "codeDesc": "山东",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "113",
      "codeName": "Shanxi1013",
      "codeNameCn": "山西",
      "parentCodeName": "China",
      "codePath": ",China,Shanxi1013,",
      "codeIndex": 1013,
      "codeValue": 1013,
      "codeDesc": "山西",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "114",
      "codeName": "Shanxi1014",
      "codeNameCn": "陕西",
      "parentCodeName": "China",
      "codePath": ",China,Shanxi1014,",
      "codeIndex": 1014,
      "codeValue": 1014,
      "codeDesc": "陕西",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "116",
      "codeName": "Tianjin1016",
      "codeNameCn": "天津",
      "parentCodeName": "China",
      "codePath": ",China,Tianjin1016,",
      "codeIndex": 1016,
      "codeValue": 1016,
      "codeDesc": "天津",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "117",
      "codeName": "Xizang1017",
      "codeNameCn": "西藏",
      "parentCodeName": "China",
      "codePath": ",China,Xizang1017,",
      "codeIndex": 1017,
      "codeValue": 1017,
      "codeDesc": "西藏",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "118",
      "codeName": "Yunnan1018",
      "codeNameCn": "云南",
      "parentCodeName": "China",
      "codePath": ",China,Yunnan1018,",
      "codeIndex": 1018,
      "codeValue": 1018,
      "codeDesc": "云南",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    },
    {
      "id": "119",
      "codeName": "Zhejiang1019",
      "codeNameCn": "浙江",
      "parentCodeName": "China",
      "codePath": ",China,Zhejiang1019,",
      "codeIndex": 1019,
      "codeValue": 1019,
      "codeDesc": "浙江",
      "jsonParams": null,
      "createdAt": "2019-02-20 09:03:00",
      "treeCount": 0
    }

    ],

    voteDialogStatus: false, // 投票弹框
    voteTimes: 10,      // 投票次数
    voteCode: 200,      // 投票结果code码

    buttonClicked: false,    // 防止连续点击
    isShow: false,            // Back组件显示隐藏
    pageUrl: '/pages/index/index',             // Back组件跳转页面地址
    voteDefaultSmall: app.globalData.mediaUrl + '/islGame_activity/vote__default--small.png',              // 默认图片
  },

  /*
   * 获取所有class类名相同Element元素的区域集合（高度集合）方法封装
   * element:class类名
   * callBack:回调函数
  */
  getElementPosition(element, callBack) {
    var query = wx.createSelectorQuery()
    query.selectAll(element).boundingClientRect()
    query.exec(function (res) {
      callBack(res)
    })
  },
  // 选择城市显示弹框
  showCityDialog() {
    this.setData({
      cityDialog: !this.data.cityDialog
    })
  },
  // 选择城市名称，并锚点到指定城市列表位置
  selectedCity(e) {
    // 当前城市索引值
    let index = e.currentTarget.dataset.index
    /*
     * 根据所选城市的index索引值，获取当前索引值之前所有指定元素的区域(高度)之和
    */
    let scrollTop = 0
    this.getElementPosition('.vote', (res) => {
      for (let i = 0; i < index; i++) {
        scrollTop += res[0][i].height
      }
      // scrollTop应用在<scroll-view>的scroll-top="{{scrollTop}}" 实现滚动到指定位置
      this.setData({
        scrollTop: scrollTop
      })
    })
    // 设置Data数据
    this.setData({
      cityDialog: !this.data.cityDialog,
      citySelecteText: this.data.getProvinceData[index].codeNameCn
    })
  },
  /*
   * 滚动古树投票列表，改变下拉框中的城市名称
   * scrollChangeText是scroll-view绑定的滚动事件
  */
  scrollChangeText(e) {
    // 当前scroll-view滚动条的scrollTop值
    // console.log(e);
    let scrollTop = e.detail.scrollTop
    let cityAreaArray = this.data.cityAreaArray
    for (let i = 0; i < cityAreaArray.length; i++) {
      if (cityAreaArray[i] > scrollTop) {
          console.log(this.data.getProvinceData[i].codeNameCn);
        if (this.data.currentIndex != i) {

          this.setData({
            citySelecteText: this.data.getProvinceData[i].codeNameCn,
            currentIndex: i
          })
        }
        break;
      }
    }
  },
  // 跳转到活动介绍页
  toIntro(e) {
    if (!this.data.buttonClicked) {
      // console.log('banner跳转地址：', e)
      let url = e.currentTarget.dataset.path
      if (url) {
        wx.navigateTo({
          url: url,
        })
      }
    }
  },
  // 跳转排行榜
  toRanking(e) {
    wx.navigateTo({
      url: '/packageVote/pages/ranking/ranking'
    })
  },
  // 跳转到详情页
  toDetail(e) {
    if (!this.data.buttonClicked) {
      let id = e.currentTarget.dataset.id // 树id
      let voteId = e.currentTarget.dataset.voteId // 活动id
      // console.log('跳转详情Id:', id)
      // console.log('投票活动id:', voteId)
      wx.navigateTo({
        url: '/packageVote/pages/detail/detail?id=' + id + '&voteId=' + voteId,
      })
    }
  },
  /*
   * 投票
   * API:于若鹏
  */
  toVote(e) {
    let id = e.currentTarget.dataset.id // 投票古树Id
    let voteId = e.currentTarget.dataset.voteId // 投票活动id
    // console.log('投票树id:',id)
    // console.log('投票活动id:', voteId)
    // 同一棵古树重复投票
    let voteStatus = e.currentTarget.dataset.voteStatus
    if (voteStatus) {
      this.setData({
        voteDialogStatus: true,
        voteCode: 201,
      })
      return
    }
    // 第一投票
    util.newRequest.post('/operating/vote/votingActivityVoting', {
      voteId: voteId,
      voteItemId: id,
    })
      .then(res => {
        // console.log('投票结果', res)
        let voteCode = res.data.data.code           // 投票结果状态码
        let voteTimes = res.data.data.voteUserTimes // 投票次数限制
        // 控制弹框
        this.setData({
          voteDialogStatus: true,
          voteCode: voteCode,
          voteTimes: voteTimes
        })
        // 刷新古树列表数据
        this.getTreeData()
      })
      .catch(res => console.log('投票请求异常', res))
  },
  /*
   * 初始化数据-调用方法
   * 以下请求接口的参数都是定值，所以不需要像detail中的app.globalData.needauth授权判断
  */
  initMethod() {
    // 古树banner列表
    // this.getTreeBanner()
    // // 省份数据
    // this.getProvinceData()
    // // 古树列表
    this.getTreeData()
    // 获取二维码code和图片
    // this.getQrCode()
  },
  getTreeData() {
    util.emit('treeListFinished')
    return;
  util.newRequest.post('/operating/vote/votingActivityObj', {
      voteId: 101
    })
    .then(res => {
      // 设置数据
      this.setData({
        getTreeData: res.data.data
      })
      // 古树数据加载完成后，计算.vote的height集合
      util.emit('treeListFinished')
    })
    .catch(res => console.log('古树数据列表请求异常', res))
},
  // 监听页面加载
  onLoad: function (options) {
    // 如果options.shareType不为空，则表示是通过分享好友进入的，显示Back返回按钮组件
    if (options.shareType) {
      this.setData({
        isShow: true,
      })
    }
  },
  // 监听页面显示
  onShow: function () {
    // 初始化数据
    this.initMethod()
    // 古树列表数据加载完成后，然后再获取城市古树区域height集合
    /*
     * 等待古树投票列表加载完成后，在进行区域高度的计算
    */
    util.on('treeListFinished', () => {
      // console.log('树木加载完成')
      this.getElementPosition('.vote', (res) => {
        // res[0]中保存着元素的高度值
        // 获取所有.vote类元素集合
        let elements = res[0]
        // 所有.vote元素的length长度
        let elementsLength = elements.length
        // 将每个.vote元素前面的区域高度集合进行收集
        let cityAreaValue = 0
        let cityAreaArray = [] // ['10','20','30']
        for (let i = 0; i < elementsLength; i++) {
          cityAreaValue += elements[i].height
          cityAreaArray.push(cityAreaValue)
          this.setData({
            cityAreaArray: cityAreaArray,
          })
        }
      })
    })
  },
  // 监听页面隐藏
  onHide: function () {

  },

})
